/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package argentracker.activeentity.property;

import argentracker.activeentity.ActiveEntity;
import argentracker.activeentity.P;

/**
 * briefly description.
 * 
 * extense description.
 * 
 * @author matero (matero _at_ gmail _dot_ com)
 */
public class StringProperty<AE extends ActiveEntity<AE>> extends P<String, AE> {

    /**
     * Constructs an string property with no name and <code>null</code> as default value.
     */
    public StringProperty() {
        this(NO_NAME, null);
    }

    /**
     * Construts an string property defining its name, and setting <code>null</code> as default value.
     * 
     * @param propertyName
     */
    public StringProperty(String propertyName) {
        this(propertyName, null);
    }

    /**
     * Constructs an string property defining its name and default value.
     * 
     * @param propertyName
     */
    public StringProperty(String propertyName, String propertyDefaultValue) {
        super(String.class, propertyName, propertyDefaultValue);
    }

    @Override
    public String interpret(Object value) {
        return (String) value;
    }

    @Override
    public Object traduct(String value) {
        return value == null ? getDefaultValue() : value;
    }
}
